package desktop.local.single;

import desktop.core.bar.Bar;
import pulpcore.image.CoreImage;
import pulpcore.sprite.Group;
import pulpcore.sprite.ImageSprite;

public class NextBarView extends Group {
	private Bar nextBar;

	public NextBarView(double x, double y, double width, double height,
			Bar nextBar) {
		super(x, y, width, height);
		this.add(new ImageSprite(CoreImage.load("nextBarBackground.jpg"), 0, 0,
				this.width.get(), this.height.get()));
		this.loadNextBar(nextBar);
	}

	public void loadNextBar(Bar bar) {
		if (this.nextBar != bar) {
			this.remove(this.nextBar);
			try {
				this.nextBar = (Bar) bar.clone();
			} catch (CloneNotSupportedException e) {
				e.printStackTrace();
			}
			this.nextBar.x.set(this.width.get() / 2 - this.nextBar.width.get()
					/ 2);
			this.nextBar.y
					.set((this.height.get() - this.nextBar.height.get()) / 2);
			this.add(this.nextBar);
		}
	}
}